package com.m3958.logcollector.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.data.rest.core.annotation.RestResource;
import org.springframework.security.access.annotation.Secured;

import com.m3958.logcollector.domain.TreeBlob;
import com.m3958.logcollector.vo.RoleNames;


@RepositoryRestResource(collectionResourceRel = "trees", path = "trees")
public interface TreeBlobRepository  extends JpaRepository<TreeBlob, Long>, TreeBlobRepositoryCustom, JpaSpecificationExecutor<TreeBlob> {
    
    @Override
    @Secured(RoleNames.SYSTEM_MANAGER)
    <S extends TreeBlob> S save(S entity);
    
    @Override
    Page<TreeBlob> findAll(Specification<TreeBlob> spec, Pageable pageable);
    
    @Override
    TreeBlob findOne(Long id);
    
    @RestResource(rel = "nameIs", path = "nameIs")
    TreeBlob findByName(@Param("name") String name);
    
    @Override
    @Secured(RoleNames.SYSTEM_MANAGER)
    void deleteAll();
}
